package com.github.fancyideas.utils;

import java.util.Random;
import java.util.Set;

public class RandomUtil {

    private RandomUtil() {

    }


    public static int getRandomInt(int min, int max) {
        Random r = new Random();
        return r.ints(min, (max + 1)).limit(1).findFirst().getAsInt();
    }


    public static int getRandomIntWithExclude(int min, int max, Set<Integer> exclude) {
        Random r = new Random();
        if (min == max) {
            throw new IllegalArgumentException("min and max can not equal");
        }
        return r.ints(min, (max + 1)).filter((the) -> !exclude.contains(the)).limit(1).findFirst().getAsInt();
    }

    public static String getRandomIntAsString(int min, int max) {
        Random r = new Random();
        return String.valueOf(r.ints(min, (max + 1)).limit(1).findFirst().getAsInt());
    }


}
